// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   BigIntegerConverter.java

package com.vandagroup.common.converters;

import java.math.BigInteger;
import org.apache.commons.beanutils.ConversionException;
import org.apache.commons.beanutils.Converter;

// Referenced classes of package com.vandagroup.common.converters:
//            CheckNullUtil

public final class BigIntegerConverter
    implements Converter
{

    private Object defaultValue;
    private boolean useDefault;

    public BigIntegerConverter()
    {
        defaultValue = null;
        useDefault = true;
        defaultValue = null;
        useDefault = false;
    }

    public BigIntegerConverter(Object defaultValue)
    {
        this.defaultValue = null;
        useDefault = true;
        this.defaultValue = defaultValue;
        useDefault = true;
    }

    public Object convert(Class type, Object value)
    {
        if(value == null)
            if(useDefault)
                return defaultValue;
            else
                throw new ConversionException("No value specified");
        if(value instanceof BigInteger)
            return value;
        try
        {
            if(CheckNullUtil.isNull(value))
                return null;
            else
                return new BigInteger(value.toString());
        }
        catch(Exception e)
        {
            if(useDefault)
                return defaultValue;
            else
                throw new ConversionException(e);
        }
    }
}
